﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using LaughingDog.Components;
using Microsoft.Xna.Framework.Graphics;
using LaughingDog.Managers;

namespace LaughingDog.GameObjects
{
    /// <summary>
    /// A Sprite is simply a GameObject with a Renderer Component already attached.
    /// </summary>
    public class Sprite : GameObject
    {        
        /// <summary>
        /// Creates an instance of a Sprite and automatically adds it to the system.
        /// </summary>
        /// <param name="assetName">The path to the texture file to use.</param>
        public Sprite(String assetName)
        {
            GameObjectManager.Instance.AddGameObject(this);

            AddComponent<Renderer>();
            
            Renderer.Texture = AssetManager.Instance.LoadTexture2D(assetName);
        }

        /// <summary>
        /// Creates an instance of a Sprite and automatically adds it to the system.
        /// </summary>
        /// <param name="texture">The Texture2D to use.</param>
        public Sprite(Texture2D texture)
        {
            GameObjectManager.Instance.AddGameObject(this);

            AddComponent<Renderer>();
            
            Renderer.Texture = texture;            
        }
    }
}
